package com.hj.dapp.business.dept.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hj.dapp.business.dept.model.Dept;
import com.hj.dapp.business.dept.service.DeptService;
import com.hj.dapp.common.request.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;
import java.util.List;

/**
 * @author 胡奥程
 * @version 1.0
 * @date 2023/12/30
 */
@RequestMapping("/dept")
@RestController
public class DeptController {
    @Autowired
    private DeptService deptService;
    @PutMapping("/saveDept")
    public void saveDept(Dept dept, Principal principal) {
        deptService.saveDept(dept,principal);
    }
    @PostMapping("/editDept")
    public void editDept(Dept dept, Principal principal) {
        deptService.editDept(dept, principal);
    }
    @GetMapping("/listDept")
    public List<Dept> listDept(@RequestBody  Dept dept) {
        return deptService.listDept(dept);
    }

    @PostMapping("/pageDept")
    public IPage<Dept> pageDept(PageRequest<Dept> request) {
        return deptService.pageDept(request);
    }

}
